package com.demo.itextdemo;

import com.itextpdf.kernel.pdf.PdfReader;
import com.itextpdf.kernel.pdf.PdfStream;
import com.itextpdf.kernel.pdf.xobject.PdfImageXObject;

public class PDFConverter {

	public static void main(String[] args) {
		args = new String[]{"E:/Eclipse插件开发(原书第3版).pdf","E:/Eclipse插件开发(原书第3版)2.pdf"};
		if (args.length == 2) {
			if (hasJpeg2000(args[0])) {
				System.out
						.println("Contains JPEG2000 images: Converting them to JPEG...");
			} else {
				System.out
						.println("Doesn't contain any JPEG2000 images: Nothing to be done...");
			}
		} else {
			System.out
					.println("Please specify a PDF filename and a output filename as a command line arguments!");
		}
	}

	public static boolean hasJpeg2000(String s) {
		try {
			PdfReader reader = new PdfReader(s);
			System.out.println(reader.getFileLength());
			reader.getSafeFile().length();
			long n = reader.getLastXref();
			System.out.println(n);
			PdfStream pdfStream = null;
			PdfImageXObject image = new PdfImageXObject(pdfStream);
			//reader.get
			reader.close();
		} catch (Exception e) {
			e.printStackTrace();
		}
		return false;
	}

}
